Skip to content

fix(dataprotection): validate restored PV provenance before completion - #10778

Merged
leon-ape merged 16 commits into
mainfrom
bugfix/10755-validate-restore-rebind
Sep 3, 2026
Merged

fix(dataprotection): validate restored PV provenance before completion#10778
leon-ape merged 16 commits into
mainfrom
bugfix/10755-validate-restore-rebind

Conversation

@leon-ape

@leon-ape leon-ape commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Part 4 of 4 for #10755.

Problem

An already-bound target PVC was accepted as restore output without checking the target PV's claimRef or population-source annotation. Concurrent updates during the PV-to-PVC handoff could also overwrite a binding or leave the helper PV assigned to a target that uses another PV.

Changes

  • Validate the target PV's claimRef namespace, name and UID, and check that its populate-from annotation matches the target dataSourceRef name. Validate an existing target binding before initiating a helper-to-target PV transfer.
  • Wait when the target PV is not visible or its claimRef does not yet match. For helper PVs, wait for an absent or incomplete claimRef; reject a complete foreign owner.
  • Use resourceVersion-based optimistic locking for the PV transfer, helper PV rollback and target PVC binding.
  • Resume an interrupted PV-first transfer: finish binding the target PVC, or restore the helper PV's claimRef before reporting an invalid concurrent target binding.
  • Separate population completion from postReady completion. Check binding and release population resources before processing postReady; an already-released population still proceeds through postReady.
  • Return ordinary errors to controller-runtime for rate-limited retry. Explicit waits use delayed requeue, and fatal errors update the Restore condition. Non-deleting bound PVCs with terminal Restore conditions do not require source lookups.

Scope

Changes are confined to VolumePopulator and its tests. Validation uses the controller's cached client and the existing populate-from annotation. The annotation is a source-name check, not a unique restore-attempt identity or a provisioner compatibility check.

Validation

  • Full controllers/dataprotection suite, including envtest.
  • Focused tests for binding completion, target and helper claimRefs, population-source validation, resource preservation, concurrent PV/PVC updates, and interrupted-transfer recovery through Reconcile.
  • Rollback conflict retry and both Succeed/Provisioned populations continuing through postReady.
  • Dataprotection lint and diff whitespace checks.

Fixes #10755

@leon-ape leon-ape added the nopick Not auto cherry-pick when PR merged label Aug 13, 2026
@apecloud-bot

Copy link
Copy Markdown
Collaborator

Auto Cherry-pick Instructions

Usage:
  - /nopick: Not auto cherry-pick when PR merged.
  - /pick: release-x.x [release-x.x]: Auto cherry-pick to the specified branch when PR merged.

Example:
  - /nopick
  - /pick release-1.1

CLA Recheck Instructions

Usage:
  - /recheck-cla: Trigger a re-check of CLA status for this pull request.
Example:
  - /recheck-cla

@github-actions github-actions Bot added the size/L Denotes a PR that changes 100-499 lines. label Aug 13, 2026
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.30496% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.84%. Comparing base (305e2ae) to head (7c61439).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...llers/dataprotection/volumepopulator_controller.go 77.30% 25 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10778      +/-   ##
==========================================
+ Coverage   65.69%   65.84%   +0.14%     
==========================================
  Files         510      510              
  Lines       64860    64958      +98     
==========================================
+ Hits        42610    42769     +159     
+ Misses      18462    18416      -46     
+ Partials     3788     3773      -15     
Flag Coverage Δ
unittests 65.84% <77.30%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leon-ape leon-ape changed the title fix: validate restored PV provenance before completion fix(dataprotection): validate restored PV provenance before completion Aug 13, 2026
@leon-ape
leon-ape marked this pull request as ready for review August 13, 2026 10:01
@leon-ape
leon-ape requested review from a team, ldming and wangyelei as code owners August 13, 2026 10:01
@github-actions github-actions Bot added size/XL Denotes a PR that changes 500-999 lines. and removed size/L Denotes a PR that changes 100-499 lines. labels Aug 14, 2026
@github-actions github-actions Bot added size/L Denotes a PR that changes 100-499 lines. and removed size/XL Denotes a PR that changes 500-999 lines. labels Sep 1, 2026
@github-actions github-actions Bot added size/XL Denotes a PR that changes 500-999 lines. and removed size/L Denotes a PR that changes 100-499 lines. labels Sep 1, 2026
Remove the obsolete Populating-based external handler error suppression and use normal controller-runtime retries for API errors and optimistic-lock conflicts. Skip source validation for non-deleting bound terminal PVCs without changing postReady, unbound, or deletion paths. Cover retry and terminal boundaries with regression tests.
@github-actions github-actions Bot added size/XXL Denotes a PR that changes 1000+ lines. and removed size/XL Denotes a PR that changes 500-999 lines. labels Sep 3, 2026
@leon-ape

leon-ape commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

/approve

@apecloud-bot apecloud-bot added the approved PR Approved Test label Sep 3, 2026
@leon-ape
leon-ape merged commit 63373ca into main Sep 3, 2026
46 of 48 checks passed
@leon-ape
leon-ape deleted the bugfix/10755-validate-restore-rebind branch September 3, 2026 07:09
@github-actions github-actions Bot added this to the Release 1.2.0 milestone Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved PR Approved Test nopick Not auto cherry-pick when PR merged size/XXL Denotes a PR that changes 1000+ lines.

Projects

None yet

2 participants